package com.wk.code.wkserver.controller.app;

import com.wk.code.wkserver.im.WebSocketServer;
import com.wk.code.wkserver.response.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author wq
 * @date 2021-06-20 21:24
 */
@RestController
@RequestMapping("/im")
@Api(tags = "app-即时通讯管理")
public class ImController {


    /**
     * 发送消息
     *
     * @param message  消息内容
     * @param toUserId 消息ID
     * @throws IOException IOException
     */
    @ApiOperation(value = "发送消息")
    @GetMapping("/send")
    public R<String> sendMessage(String toUserId, String message, Integer type) throws IOException {
        WebSocketServer.send(message, toUserId, type);
        return R.success();
    }
}
